﻿using SD.Infrastructure.EntityBase;
using System.Text;

namespace SlamDunk.MES.Domain.Entities.ConfigurationContext
{
    /// <summary>
    /// 终端
    /// </summary>
    public class Terminal : AggregateRootEntity
    {
        #region # 构造器

        #region 00.无参构造器
        /// <summary>
        /// 无参构造器
        /// </summary>
        protected Terminal() { }
        #endregion

        #region 01.创建终端构造器
        /// <summary>
        /// 创建终端构造器
        /// </summary>
        /// <param name="terminalNo">终端编号</param>
        /// <param name="terminalName">终端名称</param>
        /// <param name="description">描述</param>
        public Terminal(string terminalNo, string terminalName, string description)
            : this()
        {
            base.Number = terminalNo;
            base.Name = terminalName;
            this.Description = description;

            //初始化关键字
            this.InitKeywords();
        }
        #endregion

        #endregion

        #region # 属性

        #region 描述 —— string Description
        /// <summary>
        /// 描述
        /// </summary>
        public string Description { get; private set; }
        #endregion

        #endregion

        #region # 方法

        #region 修改终端 —— void UpdateInfo(string terminalNo, string terminalName...
        /// <summary>
        /// 修改终端
        /// </summary>
        /// <param name="terminalNo">终端编号</param>
        /// <param name="terminalName">终端名称</param>
        /// <param name="description">描述</param>
        public void UpdateInfo(string terminalNo, string terminalName, string description)
        {
            base.Number = terminalNo;
            base.Name = terminalName;
            this.Description = description;

            //初始化关键字
            this.InitKeywords();
        }
        #endregion

        #region 初始化关键字 —— void InitKeywords()
        /// <summary>
        /// 初始化关键字
        /// </summary>
        private void InitKeywords()
        {
            StringBuilder builder = new StringBuilder();
            builder.Append(base.Number);
            builder.Append(base.Name);
            builder.Append(this.Description);

            base.SetKeywords(builder.ToString());
        }
        #endregion

        #endregion
    }
}
